<template>
    <div>
        <register
            @form ="change($event)"
            :imgUrl = 'imgUrl'
            :uuid = 'uuid'
            @phone ="sendcode($event)"
        >
        </register>
    </div>
</template>

<script>
import {user_register, user_phone} from '../../request/api'
import register from './zi_register'
export default {
    components:{
        register
    },
    data() {
        return {
            imgUrl: '',
            uuid: ''
        }
    },
    methods: {
        change(data){
            user_register(data).then(res =>{
                console.log(res)
            }).catch(err=>{
                console.log(err)
            })
        },


        getuuid(){
            var d = new Date().getTime()
            if (window.performance && typeof window.performance.now === 'function') {
                d += performance.now()
            }
            var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                var r = (d + Math.random() * 16) % 16 | 0
                d = Math.floor(d / 16)
                return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16)
            })
                return uuid
            },

        getIdentifyingCode(){
            let uuid = this.getuuid()
            console.log(uuid)
            this.uuid = uuid
            let url = 'http://127.0.0.1:8000/user/image_codes/?uuid=' + uuid
            console.log(url, '-----------1')
            // let url = 'http://192.168.56.100:8888/verify/image_codes/?uuid=66ea64aa-fbe6-11ea-a3d3-005056c00008'
            this.imgUrl = url
        },

        sendcode(data){
            console.log("开始发送短信")
            user_phone(data).then(res =>{
                console.log(res)
            }).catch(err =>{
                console.log(err)
            })
        },


    },
    created() {
        this.getIdentifyingCode()
    },
    computed: {

    }
}
</script>

<style scoped>
table{
margin: auto;
}
</style>
